package com.example.demo.config;


import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(MinioPro.class)
public class MinioConfiguration {

    @Resource
    private MinioPro minioPro;

    /**
     * 初始化 MinIO 客户端
     */
    @Bean
    public MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {
        return new MinioClient(minioPro.getUrl(), minioPro.getAccessKey(), minioPro.getSecretKey());
    }

}
